package nii.game.mobileserio.enemy;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TextureRegion;

import android.content.Context;

public class Coin {
	
	// DECLARATIONS ===================================
	
	private BitmapTextureAtlas coin_BitmapTextureAtlas;
	private TextureRegion coin_TextureRegion;
	private Sprite coin_Sprite;

	private float positionX = 0;
	private float positionY = 0;
	
	// CONTRUCTOR =====================================
	public Coin(){
		
	}
	
	//========================================|| onLoadResources ||=============================================//
	
	public void onLoadResources(Engine mEngine, Context mContext) {
		
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
		coin_BitmapTextureAtlas = new BitmapTextureAtlas(16, 16, TextureOptions.DEFAULT);
		coin_TextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(coin_BitmapTextureAtlas, mContext,
						"coin.png", 0 , 0);
		mEngine.getTextureManager().loadTexture(coin_BitmapTextureAtlas);

	}

	//==========================================|| onLoadScene ||==============================================//
	
	public void onLoadScene(Scene mScene) {

		coin_Sprite = new Sprite(this.positionX, this.positionY, coin_TextureRegion);
		coin_Sprite.setCullingEnabled(true);
		mScene.attachChild(coin_Sprite);
	}
	
	// THIẾT ĐẶT VỊ TRÍ COIN ======================
	public void setPosition(float pX, float pY){
		positionX = pX;
		positionY = pY;
	}
	
	// LẤY SPRITE =================================
	public Sprite getSprite(){
		return coin_Sprite;
	}
}
